package com.hatic.process;

import org.jxstar.dao.DaoParam;
import org.jxstar.service.BusinessObject;

/**
 * 项目验收处理。
 *
 * @author TonyTan
 * @version 1.0, 2011-10-6
 */
public class ProjectCheckBO extends BusinessObject {
	private static final long serialVersionUID = 1L;

	/**
	 * 修改项目状态为已验收
	 * @param checkids -- 验收单ID
	 * @return
	 */
	public String onMyCheck(String[] checkids) {
		if (checkids == null || checkids.length == 0) {
			setMessage("验收单ID为空！");
			return _returnFaild;
		}
		
		//更新项目记录的状态为“已完成”
		for (int i = 0, n = checkids.length; i < n; i++) {
			if (!updateOne(checkids[i])) {
				setMessage("更新状态出错！");
				return _returnFaild;
			}
		}
		
		return _returnSuccess;
	}
	/*
	private boolean updateMore(String[] checkids) {
		String sql = "update project_base set project_status = '3' where project_id = ?";
		DaoParam param = _dao.createParam(sql);
		
		for (int i = 0, n = checkids.length; i < n; i++) {
			String keyid = checkids[i];
			param.addStringValue(keyid);
			
			if (!_dao.update(param)) return false;
			param.clearParam();
		}
		return true;
	}
	*/
	private boolean updateOne(String checkid) {
		String sql = "update project_base set project_status = '3' where project_id = ?";
		_log.showDebug("----------checkid=" + checkid + "; sql=" + sql);
		
		DaoParam param = _dao.createParam(sql);
		param.addStringValue(checkid);
		
		return _dao.update(param);
	}
}
